import { createRouter, createWebHistory } from 'vue-router'
import type { App } from 'vue'
import routes from '@/router/routesStatic'
import autoloadRoutes from '@/router/autoload'

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_APP_BASE ?? '/'),
  routes: [...routes, ...autoloadRoutes],
})

export async function setupRouter(app: App) {
  app.use(router)
}

export default router
